package com.ds.app.database;

import java.io.Serializable;

import com.ds.app.inner.EIModule;
import com.ds.common.cache.CacheSizes;
import com.ds.common.cache.Cacheable;
import com.ds.common.logging.Log;
import com.ds.common.logging.LogFactory;
import com.ds.common.util.CnToSpell;
import com.ds.org.conf.OrgConstants;
import com.ds.server.eumus.ConfigCode;

public class DbModule implements EIModule,Cacheable, Serializable, Comparable<EIModule>{
	
	
	protected static Log log = LogFactory.getLog(OrgConstants.CONFIG_KEY.getType(),
			EIModule.class);
	private ConfigCode configCode=OrgConstants.CONFIG_KEY;
	private String ID;
	private String name;
	private Integer index=0;
	private String url;
	private String enName;
	private String icon;
	private String thumb;
	private Integer enabled=1;
	private Integer needRight=0;
	public Integer ifSSO;
	public String ssoId;
	public Integer moduleType;
	public String memo;
	
	public String serviceId;//服务编号（业务编号）
	
	public String serviceClass;//服务分类
	
	public Integer serviceType ;//服务类型 面向企业或个人会员
	
	public Integer serviceNumber;//服务号码（特服号）
	
	public Integer feeType;//计费类型
	
	public Integer feeValue;//价格（分为单位）
	
	public String serviceProvider;//服务提供商
	
	public Integer serviceState;//服务状态
	
	public Integer serviceLowConSumPtion;//服务抵消
	


	 DbModule(){
		
	}
	
   public Integer getEnabled() {	
		return this.enabled;
	}

	public String getID() {
		return ID;
	}

	public Integer getIndex() {
		return index;
	}
	public void setIndex(Integer index) {
		this.index = index;
	}
	public String getName() {
		return name;
	}
	
	
	public String getEnName() {
		if (enName==null){
			enName=CnToSpell.getFullSpell(this.getName());
		}
		return enName;
	}
	public void setEnName(String enName) {
		this.enName = enName;
	}
	


	
	public void setEnabled(int enabled) {
		this.enabled = enabled;
	}
	public void setID(String id) {
		ID = id;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	
	public int getCachedSize() {
		int size = 0;
	   
	    size += CacheSizes.sizeOfString(ID);
	    size += CacheSizes.sizeOfString(name);
	    size += CacheSizes.sizeOfString(configCode.getType());
	    size += CacheSizes.sizeOfString(icon);
	    size += CacheSizes.sizeOfObject(thumb);
	    size += CacheSizes.sizeOfString(index.toString());
	    
	    size += CacheSizes.sizeOfString(enabled.toString());
	    size += CacheSizes.sizeOfObject(needRight);
	   
	    size += CacheSizes.sizeOfString(ifSSO.toString());
	    size += CacheSizes.sizeOfString(ssoId);
	    size += CacheSizes.sizeOfString(moduleType.toString());
	    size += CacheSizes.sizeOfString(memo);
	 
		return size;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	@Override
	public int hashCode() {
		final int PRIME = 31;
		int result = 1;
		result = PRIME * result + ((ID == null) ? 0 : ID.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final EIModule other = (EIModule) obj;
		if (ID == null) {
			if (other.getID() != null)
				return false;
		} else if (!ID.equals(other.getID()))
			
			if (this.enName == null) {
				if (other.getEnName() != null)
					return false;
			} else if (!enName.equals(other.getEnName()))
			return false;
		return true;
	}
	
	public Integer getNeedRight() {
		return needRight;
	}
	public void setNeedRight(int needRight) {
		this.needRight = needRight;
	}
	public String getIcon() {
		return icon;
	}
	public void setIcon(String icon) {
		this.icon = icon;
	}
	public String getThumb() {
		return thumb;
	}
	public void setThumb(String thumb) {
		this.thumb = thumb;
	}
	public String getSsoId() {
		return ssoId;
	}
	public void setSsoId(String ssoId) {
		this.ssoId = ssoId;
	}
	public Integer getIfSSO() {
		return ifSSO;
	}
	public Integer getModuleType() {
		return moduleType;
	}
	public void setIfSSO(Integer ifSSO) {
		this.ifSSO = ifSSO;
	}
	public void setModuleType(Integer moduleType) {
		this.moduleType = moduleType;
	}
	public String getMemo() {
		return memo;
	}
	public void setMemo(String memo) {
		this.memo = memo;
	}
	public int compareTo(EIModule o) {
		if(o.getIndex()>this.getIndex()){
			return 1;
		}
		return 0;
	}

	public Integer getFeeType() {
		return feeType;
	}

	public void setFeeType(Integer feeType) {
		this.feeType = feeType;
	}

	public Integer getFeeValue() {
		return feeValue;
	}

	public void setFeeValue(Integer feeValue) {
		this.feeValue = feeValue;
	}

	public String getServiceClass() {
		return serviceClass;
	}

	public void setServiceClass(String serviceClass) {
		this.serviceClass = serviceClass;
	}

	public String getServiceId() {
		return serviceId;
	}

	public void setServiceId(String serviceId) {
		this.serviceId = serviceId;
	}

	public Integer getServiceLowConSumPtion() {
		return serviceLowConSumPtion;
	}

	public void setServiceLowConSumPtion(Integer serviceLowConSumPtion) {
		this.serviceLowConSumPtion = serviceLowConSumPtion;
	}

	public Integer getServiceNumber() {
		return serviceNumber;
	}

	public void setServiceNumber(Integer serviceNumber) {
		this.serviceNumber = serviceNumber;
	}

	public String getServiceProvider() {
		return serviceProvider;
	}

	public void setServiceProvider(String serviceProvider) {
		this.serviceProvider = serviceProvider;
	}

	public Integer getServiceState() {
		return serviceState;
	}

	public void setServiceState(Integer serviceState) {
		this.serviceState = serviceState;
	}

	public Integer getServiceType() {
		return serviceType;
	}

	public void setServiceType(Integer serviceType) {
		this.serviceType = serviceType;
	}
	
	
}
